﻿using System.Web.UI.WebControls;
using System.IO;
using System.Web.UI;

namespace SpiderMaster.AspNet.TradingSystem.UI.Controls
{
    /// <summary> Trading Center <see cref="Login"/> Control.
    /// </summary>
    [ReganSchroder(8, 10, 2009)]
    public partial class Login : System.Web.UI.WebControls.Login
    {
        /// <summary> Raises the <see cref="E:System.Web.UI.WebControls.Login.Authenticate"/> event to authenticate the user.
        /// </summary>
        /// <param name="e">An <see cref="T:System.Web.UI.WebControls.AuthenticateEventArgs"/> that contains the event data.</param>
        protected override void OnAuthenticate(AuthenticateEventArgs e)
        {
            try { e.Authenticated = TradingCenterMember.Login(UserName, Password); }
            catch { e.Authenticated = false; }

            base.OnAuthenticate(e);
        }

        //protected override void Render(HtmlTextWriter writer)
        //{
        //    StringWriter sw = new StringWriter();
        //    HtmlTextWriter html = new HtmlTextWriter(sw);

        //    base.Render(html);

        //    string markup = sw.ToString();
        //    //manipulate the string to remove the table and insert the div
        //    //I suggest using: markup = Regex.Replace(markup, "<table.*><tr><td>", "<div>"), etc.
        //    writer.Write(markup);
        //}
    }
}